package com.example.listviewcontacts;

import org.doubango.ngn.sip.NgnAVSession;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.hardware.camera2.params.RggbChannelVector;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class CevapEkrani extends ActionBarActivity {

	private NgnAVSession mSession;
	private Button aButton;
	private Button rButton;
	private TextView arayanNumara;
	boolean flag;
	public String numara;
	String key;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.cevap_ekrani);
		aButton = (Button) findViewById(R.id.acceptButton);
		rButton = (Button) findViewById(R.id.rejectButton);
		arayanNumara = (TextView) findViewById(R.id.arayan);

		aButton.setEnabled(false);

		Bundle extras = getIntent().getExtras();
		if (extras == null)
			return;

		mSession = NgnAVSession.getSession(extras.getLong("SIP_SESSION_ID"));
		numara = extras.getString("PHONE_NUMBER_EXTRA");
		arayanNumara.setText(numara);

		getWindow().addFlags(
				WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
						| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
						| WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES);

	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		inputDialog();

	}

	public void acceptButtonClicked(View v) {

		mSession.acceptCall();
	}

	public void rejectButtonClicked(View v) {
		if (mSession != null) {
			mSession.hangUpCall();
			finish();
		}

	}

	public void inputDialog() {
		
		AlertDialog.Builder alert = new AlertDialog.Builder(this);
		alert.setTitle(String.format("%s ariyor", numara));
		final EditText input = new EditText(this);
		alert.setView(input);
		alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
					
					 aButton.setEnabled(true);
					
					
			}
		});

		alert.setNegativeButton("Cancel",
				new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {

						finish();
					}
				});

		alert.show();

	}

}
